package ppl.tut1

import scala.collection.mutable.ArrayBuffer

abstract class IntQueue {
   def get(): Int
   def put(n: Int)

}

class BasicIntQueue extends IntQueue {
   private var buf = new ArrayBuffer[Int]
   def get() = buf.remove(0)
   def put(n: Int) {
      buf += n
      println(n + "  is put")
   }
}

trait DoublingEven extends IntQueue {
   abstract override def put(n: Int) {
      val m = n % 2
      m match {
         case 0 => super.put(n * 2)
         case _ =>
      }
   }
}

object IntQueue {
   def main(args: Array[String]): Unit = {
      val c = new BasicIntQueue with DoublingEven
      c.put(2)
      c.put(3)
      c.put(4)
      println(c.get())
      println(c.get)
   }
}